package com.fzkj.thread.demo8;

// 消费者
public class Consumer extends Thread {

    private Market market;

    public Consumer(Market market) {
        this.market = market;
    }

    @Override
    public void run() {
        while(true){
            synchronized (market){
                try {
                    if (market.isEmpty){ // 为空
                        market.wait();
                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                // 生产产品
                System.out.println("消费产品。。。。。。。。");
                market.setEmpty(true);
                market.notify();
            }
        }
    }
}
